package chan.module.project.database.vastdata.bcg;

public class TestMeta {
    public static void main(String[] args) {
       /* StringBuilder sqlSb = new StringBuilder();
        sqlSb.append("SELECT ").append("\n")
                .append("\t").append("A.tablename,A.indexname,C.indexrelid,C.indnatts,C.indisunique,G.attname,b.amname,C.INDISPRIMARY").append("\n")
                .append("FROM pg_am b ").append("\n")
                .append("\t").append("LEFT JOIN pg_class f ON b.oid = f.relam ").append("\n")
                .append("\t").append("LEFT JOIN pg_attribute G ON G.attrelid = f.oid").append("\n")
                .append("\t").append("LEFT JOIN pg_stat_all_indexes e ON f.oid = e.indexrelid").append("\n")
                .append("\t").append("LEFT JOIN pg_index C ON e.indexrelid = C.indexrelid").append("\n")
                .append("\t").append(",").append("\n")
                .append("\t").append("pg_indexes A").append("\n")
                .append("\t").append("WHERE A.schemaname = e.schemaname").append("\n")
                .append("\t").append("AND A.tablename = e.relname").append("\n")
                .append("\t").append("AND A.indexname = e.indexrelname").append("\n")
                .append("\t").append("AND e.schemaname = ? ").append("\n")
                .append("\t").append("AND e.relname = ? ").append("\n");
        String querySql = sqlSb.toString();
        System.out.println(querySql);*/


        /*StringBuilder sqlSb = new StringBuilder();
        sqlSb.append("SELECT * ").append("\n")
                .append("FROM information_schema.table_constraints as c ,information_schema.key_column_usage as a").append("\n")
                .append("WHERE c.CONSTRAINT_NAME = a.CONSTRAINT_NAME").append("\n")
                .append("\t").append("AND c.table_schema = '").append("dvp_etl3").append("'").append("\n")
                .append("\t").append("AND c.TABLE_NAME = '").append("t1").append("'").append("\n")
                .append("\t").append("AND a.COLUMN_NAME='").append("c_id").append("'").append("\n");
        String sql = sqlSb.toString();*/

        /*String sql = "select c.table_schema,c.table_name ,a.column_name, "
                + "max(case when c.constraint_type = 'PRIMARY KEY' then 1 else 0 end) as primary , "
                + "max(case when c.constraint_type = 'UNIQUE' then 1 else 0 end) as unique, "
                + "max(case when c.constraint_type = 'FOREIGN KEY' then 1 else 0 end) as fk "
                + "from information_schema.table_constraints as c ,information_schema.key_column_usage as a "
                + "WHERE c.CONSTRAINT_NAME = a.CONSTRAINT_NAME "
                + "group by c.table_schema,c.table_name ,a.column_name";*/

        /*String sql = "SELECT t1.table_schema,t1.table_name,t2.column_name,t3.table_schema,t3.table_name,t3.column_name from information_schema.table_constraints t1 "
                + "join information_schema.key_column_usage t2 on t1.constraint_name = t2.constraint_name "
                + "join information_schema.constraint_column_usage t3 on t1.constraint_name = t3.constraint_name "
                + "where t1.constraint_type = 'FOREIGN KEY'";*/

        /*String sql = "SELECT e.schemaname,A.tablename,A.indexname,C.indexrelid,C.indnatts,C.indisunique,G.attname,b.amname,c.INDISPRIMARY,obj_description (c.indexrelid) as comment "
                + "FROM pg_am b " + "LEFT JOIN pg_class f ON b.oid = f.relam "
                + "LEFT JOIN pg_attribute G ON G .attrelid = f.oid "
                + "LEFT JOIN pg_stat_all_indexes e ON f.oid = e.indexrelid "
                + "LEFT JOIN pg_index C ON e.indexrelid = C .indexrelid," + "pg_indexes A "
                + "WHERE A .schemaname = e.schemaname " + "AND A .tablename = e.relname "
                + "AND A .indexname = e.indexrelname";*/

        String sql = "select t1.reltuples as rowCounts,t1.relhassubclass,t1.relname,t2.nspname,t3.description as comment from pg_class t1 join pg_namespace t2 on t1.relnamespace = t2.oid left join pg_description t3 on t1.oid =t3.objoid and t3.objsubid = 0\n"
                + "where t2.nspname not in ('pg_toast','pg_catalog','information_schema')";
        // jdbc:vastbase://10.10.92.145:5432/btongdvp?currentSchema=dvp_etl3
        System.out.println(sql);

    }
}
